import { Body, Controller, Post, UploadedFile, UseGuards, UseInterceptors } from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { JwtGuard } from 'src/common/guards/jwt.guard';
import { UploadImageDto } from './dto/upload-image.dto';
import { UploadService } from './upload.service';

@Controller('upload')
@ApiTags('上传')
export class UploadController {
    constructor(private readonly uploadService: UploadService) {}

    @Post('image')
    @ApiOperation({summary:'上传图片'})
    @ApiResponse({type:String})
    @ApiBearerAuth()
    @UseGuards(JwtGuard)
    @UseInterceptors(FileInterceptor('file'))
    uploadImage(@UploadedFile() file,@Body() uploadImageDto:UploadImageDto){
        return this.uploadService.uploadImage(file,uploadImageDto)
    }
}
